package com.migration.model.migration.scripts;

import com.migration.model.migration.AbstractMigrationScript;

/**
 * opc全量位号表(risk_opc_tags)迁移脚本
 */
public class A019_RiskOpcTagsMigrationScript extends AbstractMigrationScript {

    /**
     * 构造函数，初始化迁移配置
     */
    public A019_RiskOpcTagsMigrationScript() {
        super(
            "risk_opc_tags",
            "opc全量位号数据迁移",
            "ra_opc_tags",
            "risk_opc_tags",
            19
        );
    }

    /**
     * 生成迁移数据的SQL
     *
     * @return 迁移数据的SQL
     */
    @Override
    protected String generateMigrationSql() {
        return "INSERT INTO risk_opc_tags (\n" +
                "    id,\n" +
                "    opc_tag_name,\n" +
                "    browse_name,\n" +
                "    alarm_desc,\n" +
                "    tag_val_type,\n" +
                "    client_handle,\n" +
                "    server_handle,\n" +
                "    sub_status,\n" +
                "    equip_code,\n" +
                "    opc_menu_id,\n" +
                "    top_equip_code,\n" +
                "    opc_info_id,\n" +
                "    int_value,\n" +
                "    double_value,\n" +
                "    bool_value,\n" +
                "    tenant_id,\n" +
                "    is_del,\n" +
                "    create_time,\n" +
                "    create_by,\n" +
                "    update_time,\n" +
                "    update_by\n" +
                ")\n" +
                "SELECT\n" +
                "    id,\n" +
                "    name,\n" +
                "    browse_name,\n" +
                "    alarm_desc,\n" +
                "    type,\n" +
                "    client_handle,\n" +
                "    server_handle,\n" +
                "    sub_status,\n" +
                "    equip_code,\n" +
                "    opc_menu_id,\n" +
                "    top_equip_code,\n" +
                "    opc_info_id,\n" +
                "    int_value,\n" +
                "    double_value,\n" +
                "    bool_value,\n" +
                "    1 as tenant_id,\n" +
                "    is_del,\n" +
                "    DATE_FORMAT(create_time, '%Y-%m-%d %H:%i:%s'),\n" +
                "    1,\n" +
                "    DATE_FORMAT(update_time, '%Y-%m-%d %H:%i:%s'),\n" +
                "    1\n" +
                "FROM risk_lunnan_test.ra_opc_tags;";
    }

}
